//
//  OperationViewController.m
//  pocketNews
//
//  Created by DS on 2018/10/31.
//  Copyright © 2018年 徐双. All rights reserved.
//

#import "OperationViewController.h"
#import "Keyboard.h"

@interface OperationViewController ()
{
    UILabel *showView;
}
@end

@implementation OperationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    int width=[[UIScreen mainScreen] bounds].size.width;
    int height=[[UIScreen mainScreen] bounds].size.height;//获得屏幕宽高，下面需要使用来设置控件大小
    
    showView=[[UILabel alloc]initWithFrame:CGRectMake(0,height64, width,200 - height64)];
    showView.backgroundColor=[UIColor darkGrayColor];
    showView.tag=1;//设置tag，方便后面对他操作
    [showView setTextAlignment:NSTextAlignmentRight];
    [showView setFont:[UIFont systemFontOfSize:40]];
    [self.view addSubview:showView];
    
    //创建了一个自定义视图，显示键盘，并且按键监控
    Keyboard *key=[[Keyboard alloc]initWithFrame:CGRectMake(0, 200, width, height-200)];
    [self.view addSubview:key];
    showView .text =[NSString stringWithFormat:@"%@",key.result];//设置显示的结果
    
    
    self.title = @"计算器";
    
    UIButton *btn1 =[[UIButton alloc]initWithFrame:CGRectMake(0,0, 22, 22)];
    
    [btn1 addTarget:self action:@selector(onClick:) forControlEvents:UIControlEventTouchUpInside];
    [btn1 setBackgroundImage:[[UIImage imageNamed:@"fanhui"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
    
    UIBarButtonItem *item = [[UIBarButtonItem alloc]initWithCustomView:btn1];
    self.navigationItem.leftBarButtonItem  = item;
}

-(void)onClick:(UIButton *)btn{
    [self.navigationController popViewControllerAnimated:YES];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    
    UIAlertView *alrt=[[UIAlertView alloc]initWithTitle:@"" message:@"" delegate:self cancelButtonTitle:@"" otherButtonTitles:@"", nil];
    [alrt show];
}


@end
